<?php

/**
 * BH造型单表model
 * @author perry
 */

namespace Home\Model;

use Think\Model;

class BHTypeModel extends Model {


    /**
     * 初始化
     */
    function _initialize() {
        $this->tableName = 'bh_type';
        // $this->trueTableName  = 'eosi_bh_looks';
        $this->imgUploadType='bhtype';
    }
    
    function getAllEnabled(){
    	$map=array('status'=>1);
    	$field="id,name,img,choose_img,create_time";
    	$orderBy="show_order desc";
    	return $this->getAll($map,$field,$orderBy);
    }

    function getAll($map,$field="*",$orderBy="update_time desc"){
    	$re=$this->where($map)->field($field)->order($orderBy)->select();
    	foreach ($re as $key => &$value) {
            if(array_key_exists('img', $value)){
        		$value['img']=ic_getUploadImgFullPath($this->imgUploadType,$value['img'],$value['create_time']);
        	}
            if(array_key_exists('choose_img', $value) && ic_checkUnEmpty($value['choose_img'])){
                $value['choose_img']=ic_getUploadImgFullPath($this->imgUploadType,$value['choose_img'],$value['create_time']);
            }
        }
    	return $re;
    }

    

}
